<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" content="jure_html">
    <script src="../../static/test_t/download_lib.js"></script>
    <script src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script>
    <script src="http://pstatic.xunlei.com/js/thunderBatch.js"></script>
    <script src="http://pstatic.xunlei.com/js/base64.js"></script>
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
function down2(){
	Downer(["../../static/test_t/test.txt","../../static/test_t/test.jpg"]);
}
  function  onDownloadFiles() {

    Downer({
		"1.txt":"../../static/test_t/test.txt",
		"2.jpg":"../../static/test_t/test.jpg",
		"3.pdf":"../../static/test_t/maple-ch02.pdf"
	});
  }
function batchDownload(){
  var pid = "12345"; //迅雷联盟合作号，没有可以随便填
    var url1 = "http:\/\/down.sandai.net/thunder7/Thunder_dl_7.9.12.4646.exe";   //下载文件1
    var title1 = "迅雷7";    //文件1标题
    var url2 = "http:\/\/down.sandai.net/thundervip/ThunderVIP_Setup.exe";   //下载文件2
    var title2 = "迅雷VIP尊享版";    //文件2标题

    Download("http://127.0.0.1/static/test_t/test.jpg");
    {#BatchTasker.BeginBatch(2,pid);    //开始批量添加#}
    {#BatchTasker.AddTask(ThunderEncode(url1), title1);    //添加下载任务1，标题名称可不传#}
    {#BatchTasker.AddTask(ThunderEncode(url2), title2);    //添加下载任务2#}
    {#BatchTasker.EndBatch(pid);    //结束添加，开始下载#}

}
    //初始化迅雷插件
function InitialActiveXObject(){
 var Thunder;
 try{
  Thunder = new ActiveXObject("ThunderAgent.Agent")
 }catch(e){
  try {
   Thunder=new ActiveXObject("ThunderServer.webThunder.1");
     }catch(e){
       try{
     Thunder = new ActiveXObject("ThunderAgent.Agent.1");
             }catch(e){
     Thunder = null;
     }
        }
 }
         return Thunder;
}
//开始下载
function Download(url){
 var Thunder = InitialActiveXObject();
 if(Thunder == null){
  DownloadDefault(url);
  return;
 }
 try{
  Thunder.AddTask(url,"","","","",1,1,10);
  Thunder.CommitTasks();
 }catch(e){
  try{
   Thunder.CallAddTask(url,"","",1,"","");
  }catch(e){
   DownloadDefault(url);
  }
 }
}
//容错函数，打开默认浏览器下载
function DownloadDefault(url){
 alert('打开浏览器下载.......');
}
</script>
    <a href="javascript:" onclick="down2()" >多个文件</a>
<button onclick="batchDownload()">批量下载</button>
</body>
</html>

